<template>
  <div class="floor" v-if="data">
    <h2 class="floor-top">热门景点</h2>
    <div class="recom-mend">
      <!-- 相同组件推荐区域 -->
      <div class="recommend_s1">
        <div class="rec_right">
          <swiper
            style="position: relative"
            class="swiper"
            :options="swiperOption"
          >
            <swiper-slide v-for="{ pic, jid, title } in data.data" :key="jid">
              <div @click="goDetail(jid)">
                <a href="">
                  <div>
                    <img class="city_photo" :src="`img/${pic}`" alt="" />
                    <button>
                      <i class="el-icon-star-off">&#xe603;</i>
                    </button>
                  </div>
                  <div>{{ title }}</div>
                  <div>
                    <div>
                      <el-rate
                        v-model="value"
                        disabled
                        show-score
                        text-color="#ff9900"
                        score-template="{value}"
                      >
                      </el-rate>
                    </div>
                  </div>
                </a>
              </div>
            </swiper-slide>
            <div
              style="position: absolute; top: 30%; left: 0px"
              class="swiper-button-prev rot"
              slot="button-prev"
            >
              <svg viewBox="0 0 24 24" width="24px" height="24px">
                <path
                  d="M10.304 3.506l-8.048 8.047a.644.644 0 000 .895l8.048 8.047a.624.624 0 00.883 0l.882-.883a.624.624 0 000-.883l-5.481-5.48h14.714a.625.625 0 00.623-.625v-1.248a.624.624 0 00-.623-.624H6.588l5.481-5.481a.624.624 0 000-.883l-.882-.883a.623.623 0 00-.883-.004c-.001.002-.002.003 0 .005z"
                ></path>
              </svg>
            </div>
            <div
              style="position: absolute; top: 30%; right: 17px"
              class="swiper-button-next rot"
              slot="button-next"
            >
              <svg viewBox="0 0 24 24" width="24px" height="24px">
                <path
                  d="M13.696 3.502a.624.624 0 00-.884.004l-.882.883a.624.624 0 000 .883l5.481 5.481H2.698a.624.624 0 00-.623.624v1.248c0 .346.279.623.623.625h14.714l-5.481 5.48a.624.624 0 000 .883l.882.883c.245.244.64.244.883 0l8.049-8.047a.646.646 0 000-.895l-8.049-8.048v-.004z"
                ></path>
              </svg>
            </div>
          </swiper>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { jingdianApi } from "../api/user.js";
export default {
  data() {
    return {
      data: [],
      jid: "",
      value: 5,
      swiperOption: {
        slidesPerView: 4,
        spaceBetween: 30,
        navigation: {
          nextEl: ".swiper-button-next",
          prevEl: ".swiper-button-prev",
        },
      },
    };
  },
  mounted() {
    //获取景点
    // this.axios.get("jingdianlist").then(res => {
    //   console.log(res);
    //   this.data = res.data;
    //   console.log(this.data);
    // });
    jingdianApi().then(res => {
      this.data = res.data;
    });
  },
  methods: {
    goDetail(id) {
      this.$router.push(`/detail?jid=${id}`);
    },
    // async getyoujiApi() {
    //   let;
    // },
  },
};
</script>

<style lang="scss" scoped>
* {
  margin: 0;
  padding: 0;
}
h2 {
  margin-left: 20px;
}
.floor {
  margin: 40px auto;
  width: 1280px;
}
// 推荐区域左侧简介
.recommend_s1 {
  display: flex;
  padding: 24px;
  .rec_left {
    width: 400px;
    margin-right: 5px;
    div {
      font-size: 20px;
      font-weight: 80;
      margin-bottom: 8px;
    }
    a {
      color: #000;
      font-size: 18px;
      font-weight: bold;
    }
  }
  // 推荐区域右侧手动轮播
  .rec_right {
    width: 1280px;
    a {
      text-decoration: none;
      color: #000;

      div:nth-child(1) {
        display: flex;
        position: relative;

        button {
          position: absolute;
          background-color: white;
          right: 24px;
          top: 8px;
          width: 30px;
          height: 30px;
          border: none;
          border-radius: 50%;
          padding: 5px;
          i {
            font-size: 20px;
          }
        }
      }
      div:nth-child(2) {
        font-size: 20px;
        margin: 8px 0;
      }
      div:nth-child(4) {
        color: #333333;
      }
      .city_photo {
        width: 280px;
        height: 240px;
        margin-right: 5px;
        &:hover {
          opacity: 0.7;
        }
      }
    }
  }
}
.swiper-container {
  --swiper-navigation-size: 0;
}

.swiper-button-prev,
.swiper-button-next {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  padding: 6px;
  background-color: white;
  border: 1px solid black;
  &:hover {
    background-color: #e4e4e4;
    color: white;
  }
}
//轮播图按钮禁用时不显示
.swiper-button-disabled {
  opacity: 0;
}
</style>
